package experiment.controller;

import java.io.IOException;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import experiment.annatation.RequirePermission;
import experiment.exception.BusiException;
import experiment.model.UserPOJO;
import experiment.service.IUserService;
import experiment.service.UserServiceImpl;
import experiment.utils.EncryptionUtil;
import experiment.response.ResultVO;

@Controller
@RequestMapping("user")
public class UserController {
	
	@Autowired
	private IUserService userServiceImpl;
	
	@PostMapping("/login")
	@ResponseBody 
	public ResultVO login(@RequestBody UserPOJO user, HttpSession session) throws IOException, BusiException {
		userServiceImpl.login(user, session);
		return new ResultVO();
	}
	
	@PostMapping("/register")
	@ResponseBody 
	public ResultVO register(@RequestBody  UserPOJO user) throws IOException {
		userServiceImpl.register(user);
		return new ResultVO();
	}
	
	@RequirePermission
	@GetMapping("/vippage")
	@ResponseBody
	public ResultVO vippage() {
		return new ResultVO();
	}

	@GetMapping("/page")
	@ResponseBody
	public ResultVO page() {
		return new ResultVO();
	}

}

